package com.luck.emp.check.vo;

import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;

import com.luck.emp.entity.EmpTWhCheckD;
import com.luck.emp.entity.EmpTWhCheckM;
import com.luck.pf.util.XlsExcel;

public class CheckDetailExcel extends XlsExcel {
	EmpTWhCheckM check;
	
	@Override
	public void buildBody(List data) {
		HSSFSheet sheet = getSheetAt(0);
		for (int i = 0, len = data.size(); i < len; i++) {			
			EmpTWhCheckD next = (EmpTWhCheckD)data.get(i);
			
			HSSFRow row = sheet.createRow(i + getFromIdx());
			int idxCell = 0;
			
			createCell(row, idxCell++, next.getProduct().getName());
			createCell(row, idxCell++, next.getProductCode());
			createCell(row, idxCell++, next.getProduct().getProdBarcode());
			createCell(row, idxCell++, next.getProduct().getMeasUnitStr());
			createCell(row, idxCell++, next.getPlanQty().toString());
		}
	}

	@Override
	public void buildFoot() {
	}

	@Override
	public void buildHeader(Object headData) {
		HSSFSheet sheet = getSheetAt(0);
		HSSFRow row = sheet.getRow(0);
		HSSFCell checkCode = row.getCell(1);
		HSSFCell whName = row.getCell(3);
		HSSFCell whCode = row.getCell(4);
		HSSFCell checkType = row.getCell(6);
		
		checkCode.setCellValue(check.getCheckCode());
		whCode.setCellValue(check.getWh().getWhCode());
		whName.setCellValue(check.getWh().getWhName());
		if(check.getCheckType().equals("1"))
			checkType.setCellValue("明盘");
		else
			checkType.setCellValue("暗盘");
	}

	public EmpTWhCheckM getCheck() {
		return check;
	}

	public void setCheck(EmpTWhCheckM check) {
		this.check = check;
	}

	
}